package com.yfapp.platform.dao.impl;


import java.util.List;
import org.springframework.stereotype.Repository;
import com.yfapp.platform.dao.AdminDao;
import com.yfapp.platform.entity.Admin;

@Repository
public class AdminDaoImpl extends BaseDaoImpl<Admin, Integer> implements AdminDao {
	/**
	 * 管理员登陆
	 */
	public Admin login(Admin admin) {
		/*String sqlt = "select * from yf_admin";
		List<Map<String, Object>> queryForList = dbUtilsTemplate.queryForList(sqlt);
		System.out.println("1");
		System.out.println(queryForList.size());
		Map<String, Object> map = queryForList.get(0);
		System.out.println(map.toString());
		System.out.println("keyset="+map.keySet());
		System.out.println("2");*/
		dbUtilsTemplate.update("update yf_admin set loginTime= '201601051501' ");
		String sqlt = "select * from yf_admin";
		List<Admin> queryForList = dbUtilsTemplate.queryForList(Admin.class, sqlt);
		for (Admin am : queryForList) {
			//System.out.println("forid="+am.getAdminId());
		}
		
		String sql="select adminId, adminCode,adminPwd,loginTime from yf_admin where adminCode=? and adminPwd=?";
		Object[] params = { admin.getAdminCode(),admin.getAdminPwd() };
		Admin ad = dbUtilsTemplate.queryFirst(Admin.class, sql, params);
		//System.out.println(ad.getAdminId());
		return ad;
	}

	public List<Admin> getAdminList() {
		String sqlt = "select * from yf_admin";
		List<Admin> adminList = dbUtilsTemplate.queryForList(Admin.class, sqlt);
		return adminList;
	}
}
